﻿namespace Hippo.Agent.Lib
{
    using Properties;
    using Hippo.Common;

    public class AgentCommandLineParser : CommandLineParser
    {
        private readonly RegexFactory regexFactory;

        public AgentCommandLineParser(IConfigurationProfile configuration, RegexFactory regexFactory) :
            base(configuration)
        {
            this.regexFactory = regexFactory;
        }

        public override OptionSet CreateCommandLineOptions()
        {
            return new OptionSet
            {
                { 
                    "/agentName=STR", 
                    AgentOptions.AgentNameDescription, 
                    regexFactory.GetArgumentExpression("agentName", "an"), 
                    value => Configuration.Set(AgentConfigurationProfile.AgentNameIdentifier, value)
                },
                { 
                    "/consoleEndpointAddress=X", 
                    AgentOptions.ConsoleEndpointAddressDescription,
                    regexFactory.GetArgumentExpression("consoleEndpointAddress", "cea"), 
                    value => Configuration.Set(AgentConfigurationProfile.ConsoleEndpointAddressIdentifier, value)
                },
                { 
                    "/help", 
                    "Get command line help (Short format: /?)", 
                    regexFactory.HelpArgumentExpression,
                    value => GetHelp(AgentOptions.CommandLineHelp, ExitCode.Normal)
                },
            };
        }
    }
}
